home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / infoserv / www / cern / doc / www-talk.archive.Z / www-talk.archive / text0361.txt < prev    next >
Encoding:
Text File  |  1992-11-30  |  1.2 KB  |  40 lines

  1.  
  2. Here's a patch to add a function to fix all the existing
  3. HREFs in an HTML file so they'll have quotes around them.
  4.  
  5. Dan
  6.  
  7. *** /mnt/connolly/foo    Wed Nov 18 22:51:50 1992
  8. --- html-mode.el    Wed Nov 18 22:50:32 1992
  9. ***************
  10. *** 517,522 ****
  11. --- 517,543 ----
  12.                  (setq html-link-counter (1+ html-link-counter))
  13.                  (replace-string-in-buffer start (1- end)
  14.                   (format "%d" html-link-counter))))))))
  15. + (defun html-quote-hrefs ()
  16. +   "Insert quotes around all HREF attribute value literals.
  17. + This remedies the problem with old html files that can't be
  18. + processed by SGML parsers. That is, changes
  19. + <A HREF=foo> to <A HREF="foo">.
  20. + By Dan Connolly, so don't yell at Mark if it breaks."
  21. +   (interactive)
  22. +   (save-excursion
  23. +     (goto-char (point-min))
  24. +     (setq html-link-counter 0)
  25. +     (while (re-search-forward "<[aA][ \t\n]+\\([nN][aA][mM][eE]=[a-zA-Z0-9]+[ \t\n]+\\)?[hH][rR][eE][fF]=" (point-max) t)
  26. +       (cond ((null (looking-at "\""))
  27. +          (insert "\"")
  28. +          (re-search-forward "[ \t\n>]" (point-max) t)
  29. +          (forward-char -1)
  30. +          (insert "\"")
  31. +          ))
  32. +       ) ) )
  33.   
  34.   ;;; ------------------------------- html-mode --------------------------------
  35.   
  36.  
  37.